package foodhelper.healthtip;

import java.util.ArrayList;

import foodhelper.model.Tip;
import foodhelper.mtech.com.R;
import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class MyArrayAdapter extends ArrayAdapter<Tip> {
	Activity context;
	ArrayList<Tip> arrl;
	int layout;
	private TextView TitleTV;
	private TextView SourceTV;
	private Tip tip;
	
	public MyArrayAdapter(Activity context, int layout, ArrayList<Tip> arrl) {
		super(context, layout,arrl);
		this.context = context;
		this.arrl = arrl;
		this.layout = layout;
	}
	
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		
		LayoutInflater inflater = context.getLayoutInflater();
		convertView = inflater.inflate(layout,null);
		TitleTV = (TextView)convertView.findViewById(R.id.tipTitleLV);
		SourceTV = (TextView)convertView.findViewById(R.id.tipSourceLV);
		tip = arrl.get(position);	
		TitleTV.setText(tip.getTipsTitle());
		SourceTV.setText(tip.getTipsRef());
		
		return convertView;
		
	}

}
